package com.guanyong.services;

import com.guanyong.dao.IMessageReadlogDaoMapper;
import com.guanyong.model.MessageReadlogModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by mxk on 2017/6/15.
 */

@Service
public class MessageReadlogService {
    @Autowired
    IMessageReadlogDaoMapper iMessageReadlogDaoMapper;

    //添加消息日志
    public Integer AddMessageReadlog(String userid,Integer msgid){
        MessageReadlogModel messageReadlogModel=new MessageReadlogModel();
        messageReadlogModel.setfUserid(userid);
        messageReadlogModel.setfMessageid(msgid);
        return  iMessageReadlogDaoMapper.insert(messageReadlogModel);
    }

    //修改消息日志状态
    public Integer UpdateMessageReadlog(Integer fid,Integer state){

        MessageReadlogModel messageReadlogModel=new MessageReadlogModel();
        messageReadlogModel.setfId(fid);
        messageReadlogModel.setfShow(state);
        return  iMessageReadlogDaoMapper.update(messageReadlogModel);
    }

    public MessageReadlogModel SelectMessageReadlog(String userid,Integer msgid){
        return  iMessageReadlogDaoMapper.selectByUseridMsgId(userid, msgid);
    }
}
